package com.spirng.leetcode.day08;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class Test78 {
    public static void main(String[] args) {
        Test78 test78 = new Test78();
        test78.subsets(new int[]{1,2,3});
    }
    ArrayList lists=new ArrayList<List<Integer>>();
    LinkedList list=new LinkedList<Integer>();
    public List<List<Integer>> subsets(int[] nums) {
        backtracking(nums,0);
           return lists;
    }
    public void backtracking(int [] nums, int startSize){
          lists.add(new ArrayList<>(list));
         if(startSize>=nums.length){
             return;
         }
        for (int i = startSize; i < nums.length; i++) {
            list.add(nums[i]);
            backtracking(nums,i+1);
            list.removeLast();
        }
    }
}
